#pragma once
#include "structs.h"
#include "LockCS.h"
class CIOCP
{
public:
	CIOCP(void);
	~CIOCP(void);
	BOOL Init(void);
	void HandleIO(DWORD dwByteTransferred,pCLIENTINFO pClientObj,PIO_OPERATION_DATA pIoData);
	BOOL SendData(SOCKET sclient,char* buf,int len);
	BOOL RemoveClientInfo(pCLIENTINFO pclient);
	BOOL BroadcastData(char* buf,int len);
	BOOL SendDataByAddr(struct  in_addr vaddr,char* buf,int len);
	BOOL ReUseUserId(int userid);
	int GetReUseIp(char* vitualip);
	static DWORD WINAPI WorkThread(LPVOID lparam);
	static DWORD WINAPI AcceptThread(LPVOID lparam);
private:
	SOCKET m_listensock;
	HANDLE m_hcomplete;
	vector<pCLIENTINFO> m_pclientarr;
	vector<int> m_reuseuseridarr;
	CLockCS m_lock;
	CLockCS m_useridlock;
};
